package user;

/** 
 * Helper class for : corbainterface
 *  
 * @author OpenORB Compiler
 */ 
public class corbainterfaceHelper
{
    /**
     * Insert corbainterface into an any
     * @param a an any
     * @param t corbainterface value
     */
    public static void insert(org.omg.CORBA.Any a, user.corbainterface t)
    {
        a.insert_Object(t , type());
    }

    /**
     * Extract corbainterface from an any
     *
     * @param a an any
     * @return the extracted corbainterface value
     */
    public static user.corbainterface extract( org.omg.CORBA.Any a )
    {
        if ( !a.type().equivalent( type() ) )
        {
            throw new org.omg.CORBA.MARSHAL();
        }
        try
        {
            return user.corbainterfaceHelper.narrow( a.extract_Object() );
        }
        catch ( final org.omg.CORBA.BAD_PARAM e )
        {
            throw new org.omg.CORBA.MARSHAL(e.getMessage());
        }
    }

    //
    // Internal TypeCode value
    //
    private static org.omg.CORBA.TypeCode _tc = null;

    /**
     * Return the corbainterface TypeCode
     * @return a TypeCode
     */
    public static org.omg.CORBA.TypeCode type()
    {
        if (_tc == null) {
            org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
            _tc = orb.create_interface_tc( id(), "corbainterface" );
        }
        return _tc;
    }

    /**
     * Return the corbainterface IDL ID
     * @return an ID
     */
    public static String id()
    {
        return _id;
    }

    private final static String _id = "IDL:user/corbainterface:1.0";

    /**
     * Read corbainterface from a marshalled stream
     * @param istream the input stream
     * @return the readed corbainterface value
     */
    public static user.corbainterface read(org.omg.CORBA.portable.InputStream istream)
    {
        return(user.corbainterface)istream.read_Object(user._corbainterfaceStub.class);
    }

    /**
     * Write corbainterface into a marshalled stream
     * @param ostream the output stream
     * @param value corbainterface value
     */
    public static void write(org.omg.CORBA.portable.OutputStream ostream, user.corbainterface value)
    {
        ostream.write_Object((org.omg.CORBA.portable.ObjectImpl)value);
    }

    /**
     * Narrow CORBA::Object to corbainterface
     * @param obj the CORBA Object
     * @return corbainterface Object
     */
    public static corbainterface narrow(org.omg.CORBA.Object obj)
    {
        if (obj == null)
            return null;
        if (obj instanceof corbainterface)
            return (corbainterface)obj;

        if (obj._is_a(id()))
        {
            _corbainterfaceStub stub = new _corbainterfaceStub();
            stub._set_delegate(((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate());
            return stub;
        }

        throw new org.omg.CORBA.BAD_PARAM();
    }

    /**
     * Unchecked Narrow CORBA::Object to corbainterface
     * @param obj the CORBA Object
     * @return corbainterface Object
     */
    public static corbainterface unchecked_narrow(org.omg.CORBA.Object obj)
    {
        if (obj == null)
            return null;
        if (obj instanceof corbainterface)
            return (corbainterface)obj;

        _corbainterfaceStub stub = new _corbainterfaceStub();
        stub._set_delegate(((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate());
        return stub;

    }

}
